package com.sky.seata.storage.client.impl;

import com.sky.seata.storage.client.IStockClient;
import com.sky.seata.storage.entity.Stock;
import com.sky.seata.storage.service.IStockService;
import com.sky.seata.storage.util.IdGenerator;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class StockClientImpl implements IStockClient {

    @Autowired
    private IStockService stockService;

    @Override
    public void insertStock() {
        Stock stock = new Stock();
        stock.setCount(1000);
        stock.setName("seata");
        stock.setId(IdGenerator.GenerateId24());
        stockService.insert(stock);
    }

    @Override
    public void updateStock() {
        stockService.update();
        //int i = 1/0;
    }
}
